feat: add MessageLoader for loading translation scripts from JSON files#13
feat: add MessageLoader for loading translation scripts from JSON files#13
Conversation
| * | ||
| * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | ||
| */ | ||
| private function validateShape($messageId, $message): void |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| * | ||
| * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | ||
| */ | ||
| private function validateShape($messageId, $message): void |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| * @throws InvalidArgumentException | ||
| * @throws LocaleNotFoundException | ||
| */ | ||
| private function getLocaleMessages(): array |
There was a problem hiding this comment.
Function getLocaleMessages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
|
|
||
| unset($data['smartling']); | ||
|
|
||
| foreach ($data as $messageId => $message) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| { | ||
| $messages = new MessageCollection($config); | ||
|
|
||
| foreach ($data as $messageId => $message) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
|
Code Climate has analyzed commit ac8a2b1 and detected 5 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 100.0% (0.0% change). View more on Code Climate. |
Description
This provides a
MessageLoaderfor loading translation strings from JSON files.For example (I'm working on examples to put into the README, btw):
This will look for JSON files in
/path/to/locales. It will first look forfr-CA.json. If it can't find that, it looks forfr.json. Finally, if it can't find that, it usesen.json(as the default locale).Product requirements and context
How has this been tested?
PR Checklist